import 'package:flutter/material.dart';
import 'dart:ui' as ui show window;

class GTScreen {
  static double getWidth(BuildContext context) {
    return MediaQueryData.fromView(View.of(context)).size.width;
  }

  static double getHeight(BuildContext context) {
    return MediaQueryData.fromView(View.of(context)).size.height;
  }

  static double getDevicePixelRatio(BuildContext context) {
    return MediaQueryData.fromView(View.of(context)).devicePixelRatio;
  }

  static double getAppBarHeight(BuildContext context) {
    return MediaQueryData.fromView(View.of(context)).padding.top + 44.0;
  }

  static double getTopSafeHeight(BuildContext context) {
    return MediaQueryData.fromView(View.of(context)).padding.top;
  }

  static double getBottomSafeHeight(BuildContext context) {
    return MediaQueryData.fromView(View.of(context)).padding.bottom;
  }

  @Deprecated('Use GTScreen.getWidth instead.')
  static double get width {
    MediaQueryData mediaQuery = MediaQueryData.fromWindow(ui.window);
    return mediaQuery.size.width;
  }

  @Deprecated('Use GTScreen.getHeight instead.')
  static double get height {
    MediaQueryData mediaQuery = MediaQueryData.fromWindow(ui.window);
    return mediaQuery.size.height;
  }

  @Deprecated('Use GTScreen.getDevicePixelRatio instead.')
  static double get scale {
    MediaQueryData mediaQuery = MediaQueryData.fromWindow(ui.window);
    return mediaQuery.devicePixelRatio;
  }

  @Deprecated('textScaleFactor is deprecated by flutter')
  static double get textScaleFactor {
    MediaQueryData mediaQuery = MediaQueryData.fromWindow(ui.window);
    return mediaQuery.textScaleFactor;
  }

  @Deprecated('Use GTScreen.getAppBarHeight instead.')
  static double get navigationBarHeight {
    MediaQueryData mediaQuery = MediaQueryData.fromWindow(ui.window);
    return mediaQuery.padding.top + 44.0;
  }

  @Deprecated('Use GTScreen.getTopSafeHeight instead.')
  static double get topSafeHeight {
    MediaQueryData mediaQuery = MediaQueryData.fromWindow(ui.window);
    return mediaQuery.padding.top;
  }

  @Deprecated('Use GTScreen.getBottomSafeHeight instead.')
  static double get bottomSafeHeight {
    MediaQueryData mediaQuery = MediaQueryData.fromWindow(ui.window);
    return mediaQuery.padding.bottom;
  }
}
